package fr.expdev.bndd;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import fr.expdev.bndd.data.Post;

public class WebPost extends Activity {

	private AppContext _appContext = AppContext.getAppContext();

	private int _postNumber;
	private Post _post;

	private WebView _view;
	private Button _back;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.web_post);
		
		_postNumber = getIntent().getIntExtra("post_number", -1);
		if (_postNumber > -1) {
			_post = _appContext.posts.get(_postNumber);
		}
		
		_view = ((WebView) findViewById(R.id.web_post_content));
		_back = ((Button) findViewById(R.id.web_post_back));

		//_view.loadDataWithBaseURL("http://www.experience-developpement.fr/", _post.getLink(), "text/html", "utf-8", "about:blank");
		_view.getSettings().setJavaScriptEnabled(true);
		_view.loadUrl( _post.getLink());
		_back.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
	}

}
